<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>login</title>
    <link rel="stylesheet" href="https://cdn.bootcss.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">

</head>
<body>


<form class="form-horizontal" id="form" action="func/checkUserPasswd.php" method="post">
    <div class="form-group">
        <label for="username" class="col-sm-2 control-label">ACCOUNT</label>
        <div class="col-sm-10">
            <input type="text" class="form-control" id="username" placeholder="USER"><span id="checkUsername" style="color: brown"></span><br>
        </div>
    </div>
    <div class="form-group">
        <label for="psd" class="col-sm-2 control-label">Password</label>
        <div class="col-sm-8">
            <input type="password" class="form-control" name="password" id="psd" placeholder="Password"><span id="checkPasswd" style="color: brown"></span><br>
        </div>
    </div>
    <div class="form-group">
        <div class="col-sm-offset-2 col-sm-10">
            <div class="checkbox">
                <label>
                    <input type="checkbox"> Remember me
                </label>
            </div>
        </div>
    </div>
    <div class="form-group">
        <div class="col-sm-offset-2 col-sm-10">
            <button type="submit" onclick="IsEmptyUserPasswd()"  class="btn btn-default">Sign in</button>
        </div>
    </div>
</form>

<script>
    var form =document.getElementById("form");

    function IsEmptyUserPasswd() {
        var username= document.getElementById("username");
        var passwd= document.getElementById("psd");
        var usernameWaring=document.getElementById("checkUsername");
        var passwdWaring =document.getElementById("checkPasswd");

        /* clear old error data*/
        usernameWaring.innerHTML="";
        passwdWaring.innerHTML="";

        if(username.value== "") {

            usernameWaring.innerHTML="用户名不能为空";
            return;
        }

        if(passwd.value==""){

            passwdWaring.innerHTML="密码不能为空";
            return;
        }
        form.submit();
    }
</script>
</body>
</html>
